/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import bean.Formato;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author fernando
 */
public class FormatoDao implements Serializable{
      private Conexao conexao;
    private PreparedStatement ps;
    private boolean sucess = false;

    public FormatoDao() {
        this.conexao = new ConexaoPostgres();

    }
    
     public Formato consultarFormato(int id) {
        this.ps = null;
        Formato f = null;
        try {
            f = new Formato();
            ps = conexao.getConnection().prepareStatement("Select * from FORMATO where id = ?; ");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            conexao.closeConnection();
            if (rs.next()) {

                f.setFormato(rs.getString("tipo"));
                f.setId(id);


            }
        } catch (SQLException ex) {
            conexao.closeConnection();
            return f;

        }
        conexao.closeConnection();
        return f;
    }
    
}
